package org.ourgrid.worker.controller.actions;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.ourgrid.common.interfaces.WorkerSpecListener;
import org.ourgrid.common.spec.worker.WorkerSpec;
import org.ourgrid.worker.dao.WorkerSpecDAO;
import org.ourgrid.worker.dao.WorkerSpecListenerDAO;

import br.edu.ufcg.lsd.commune.container.servicemanager.ServiceManager;
import br.edu.ufcg.lsd.commune.container.servicemanager.actions.RepeatedAction;

public class ReportWorkerSpecAction implements RepeatedAction {

	public void run( Serializable handler, ServiceManager serviceManager ) {
		WorkerSpecDAO workerSpecDAO = serviceManager.getDAO(WorkerSpecDAO.class);
		WorkerSpec workerSpec = workerSpecDAO.getWorkerSpec();
		
		List<WorkerSpecListener> listeners = serviceManager.getDAO(WorkerSpecListenerDAO.class).getWorkerSpecLIsteners();
		
		for(WorkerSpecListener listener: listeners){
			listener.updateWorkerSpec(workerSpec);
		}
		
	}
		
}
